const api = require('../../utils/http.js');
const app = getApp();
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		typeId: 0,
		navArr1: ['全部', '待审核', '待打款', '已打款', '无效'],
		memberList:[{"id":1,"icon":"","name":"提现到支付宝","num":"20","time":"2019-07-18","consumption":"+3.00","type":"1","status":"待审核"},{"id":2,"icon":"","name":"提现到微信钱包","num":"10","time":"2019-07-18","consumption":"+3.00","type":"5","status":"无效"}],
    detailedList:[]
	},
	changeType(e) {
		let typeId = e.currentTarget.id
		console.log(typeId)
		this.setData({
			typeId,
      detailedList: []
		})
    this.getDetailed(1, this.data.typeId);
	},

//提现明细
  getDetailed(page,type){
    var typeText;
    type == 0 ? typeText = '全部' : type == 1 ? typeText = '待审核' : type == 2 ? typeText = '待打款' : type == 3 ? typeText = '已打款' : type == 4 ? typeText = '无效':''
    var uid = app.globalData.uid;
    api.fetchApi('procedure_t', { p: `R2010003|${uid}|${typeText}|${page}|10` }).then(res => {
      if (res.data.code == 1) {
       
        var detailedList = this.data.detailedList;
        var detailedList1 = res.data.results;
        if (detailedList1.length == 0 && page > 1) {

          api.showToast('再拉也没有啦!' + '', '', 'none')
          return
        }
        detailedList = [...detailedList, ...detailedList1]
        this.setData({
          detailedList,
          page
        })
      } else {
        api.showToast('获取数据失败!' + '', '', 'none')
      }
    })
  },
	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
    console.log(options);
    this.setData({
      commission: options.commission
    })
    this.getDetailed(1, this.data.typeId);
	},

	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {
    var page = this.data.page || 1;
    page++;
    this.getDetailed(page, this.data.typeId);
	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {

	}
})
